﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rung.Net.Enums;

namespace Rung.Net.Events
{
    /// <summary>
    /// 网络流事件基类。
    /// </summary>
    public abstract class NetStreamEventArgs : EventArgs
    {
        /// <summary>
        /// The stream's guid.
        /// </summary>
        public Guid Guid { get; private set; }

        public NetStreamEventArgs(Guid guid)
        {
            Guid = guid;
        }
    }

    /// <summary>
    /// 网络流关闭响应事件。
    /// </summary>
    public delegate void NetStreamStoppedEventHandler(object sender, NetStreamStoppedEventArgs e);
    /// <summary>
    /// 网络流关闭响应事件参数。
    /// </summary>
    public class NetStreamStoppedEventArgs : NetStreamEventArgs
    {
        /// <summary>
        /// The reason why the stream being stopped.
        /// </summary>
        public NetStoppedReason Reason { get; private set; }

        public NetStreamStoppedEventArgs(Guid guid, NetStoppedReason reason)
            : base(guid)
        {
            Reason = reason;
        }
    }

    /// <summary>
    /// 网络流开启响应事件。
    /// </summary>
    public delegate void NetStreamStartedEventHandler(object sender, NetStreamStartedEventArgs e);
    /// <summary>
    /// 网络流开启响应事件参数。
    /// </summary>
    public class NetStreamStartedEventArgs : NetStreamEventArgs
    {
        public NetStreamStartedEventArgs(Guid guid)
            : base(guid)
        {
        }
    }

    /// <summary>
    /// 网络流数据接收事件。
    /// </summary>
    public delegate void NetStreamReceivedEventHandler<T>(object sender, NetStreamReceivedEventArgs<T> e);
    /// <summary>
    /// 网络流数据接收事件参数。
    /// </summary>
    public class NetStreamReceivedEventArgs<T> : NetStreamEventArgs
    {
        /// <summary>
        /// The data received.
        /// </summary>
        public T Data { get; private set; }

        public NetStreamReceivedEventArgs(Guid guid, T data)
            : base(guid)
        {
            Data = data;
        }
    }

    /// <summary>
    /// 网络流数据接收事件。
    /// </summary>
    public delegate void FileTransferComplitedEventHandler(object sender, FileTransferComplitedEventArgs e);
    /// <summary>
    /// 网络流数据接收事件参数。
    /// </summary>
    public class FileTransferComplitedEventArgs : NetStreamEventArgs
    {
        /// <summary>
        /// 传输完成的本地文件全名。
        /// </summary>
        public string FileName { get; private set; }

        /// <summary>
        /// 传输完成的本地文件长度。
        /// </summary>
        public long FileLength { get; private set; }

        public FileTransferComplitedEventArgs(Guid guid, string fileName, long fileLength)
            : base(guid)
        {
            this.FileName = fileName;
            this.FileLength = fileLength;
        }
    }

    /// <summary>
    /// 会话结束事件。
    /// </summary>
    public delegate void SessionEndEventHandler(object sender, SessionEndEventArgs e);
    /// <summary>
    /// 会话结束事件参数。
    /// </summary>
    public class SessionEndEventArgs : NetStreamEventArgs
    {
        public SessionEndEventArgs(Guid guid)
            : base(guid)
        {
        }
    }
}
